<style type="text/css">
  table.lined_table { width: 100%; border-spacing:0; border-collapse:collapse; }
  table.lined_table td { border: solid 1px darkgrey; padding: 2px; margin:0; }
  table.lined_table th { border: solid 1px darkgrey; padding: 2px; margin:0; background-color: lightgrey; }
  label.klasse { display: inline-block; width: 44px; text-align: left; }
  @media print {
    td, th {
      font-size: 8pt;
      border-bottom: solid 1px black;
    }
    td b {
      font-size: 10pt;
    }
  }
</style>
<?
  if(!$cms->user['authorized']) {
    echo "Log eerst in";
    return;
  }
  $print=$cms->query->get['print'];
  $klasse=strtoupper($cms->query->get['klasse']);
  if(!$print) {
    if(!$cms->query->maint) {
      echo "<a href=\"home.php\">";
      echo "<center><h1>";
      echo "<img src=\"{$cms->contenturl}assets/gfx/logo.gif\" style=\"vertical-align:middle\" alt=\"ONK Labo logo\">";
      echo "ONK jury</h1></center>";
      echo "</a>\n";
    }
    $url = $cms->query->create_query('-','-','satellite');
    echo "<p><a href=\"$url?klasse=$klasse&print=1\" target=\"print\">afdrukken</a></p>\n";
    echo "<p>Klasse: ";
    $klas = array('Alles'=>'', 'A'=>'A', 'B'=>'B', 'C'=>'C', 'D'=>'D', 'E'=>'E', 'V'=>'V');
    foreach($klas as $str=>$val) {
      $checked = "";
      if ($val == $klasse) {
        $checked = "checked";
      }
      echo "<label class = \"klasse\">";
      echo "<input type = \"radio\"";
      echo " name = \"klasse\"";
      echo " id = \"klasse_$val\"";
      echo " value = \"$val\" $checked/>$str";
      echo "</label>\n";
    }
    echo "</p>\n";
  }
  if($klasse)
    $where = " AND t.klasse='$klasse'";
  $sql = "SELECT b.*, punten, t.klasse, t.label, t.naam  FROM inschrijving_bier b LEFT JOIN biertype t ON b.biertype=t.id WHERE punten>0$where ORDER BY punten DESC";
  $result = $cms->db->execute($sql);
  echo "<table class=\"lined_table\">\n";
  echo "<tr>";
  echo "<th>Nr</th>";
  echo "<th>Biertype</th>";
  echo "<th>Klasse</th>";
  echo "<th>Visueel</th>";
  echo "<th>Geur</th>";
  echo "<th>Smaak ass.</th>";
  echo "<th>Smaak</th>";
  echo "<th>Totaal</th>";
  echo "<th>eind kl.</th>";
  echo "</tr>\n";
  $prev_punten = 0;
  $klassering = 0;
  while ($row = $result->get_nextrow()) {
    $nr = sprintf("%s_%02d",$row['label'],$row['nummer']);
    if($row['punten'] != $prev_punten) {
      $klassering ++;
      $prev_punten = $row['punten'];
    }
    $naam = $row['klasse'] == 'V' ? 'V: '.$row['omschrijving_V'] : $row['naam'];
    if($row['visueel'] > 0) $visueel = $row['visueel'];
    else $visueel = '';
    if($row['geur'] > 0) $geur = $row['geur'];
    else $geur = '';
    if($row['smaak_assoc'] > 0) $smaak_assoc = $row['smaak_assoc'];
    else $smaak_assoc = '';
    if($row['smaak'] > 0) $smaak = $row['smaak'];
    else $smaak = '';
    if($row['punten'] > 0) $punten = "<b>".$row['punten']."<b>";
    else $punten = '';
    echo "<tr>";
    echo "<td>".$nr."</td>";
    echo "<td>".$naam."</td>";
    echo "<td>".$row['klasse']."</td>";
    echo "<td>".$visueel."</td>";
    echo "<td>".$geur."</td>";
    echo "<td>".$smaak_assoc."</td>";
    echo "<td>".$smaak."</td>";
    echo "<td>".$punten."</td>";
    echo "<td>".$klassering."</td>";
    echo "</tr>\n";
  }
  echo "</table>\n";
  if($print) {
    echo "<script>if(window.print) window.print();</script>\n";
  }
?>
<script type="text/javascript">
  $(document).ready(function() {
    $('input[name="klasse"]').click( function() {
      window.location.href=window.location.pathname+"?klasse="+$(this).val();
    });
  });
</script>
